<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('优惠券列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="coupon-printOnline-form">
                <div class="select-list">
                    <ul>
                        <li>
                            标题：<input type="text" name="title"/>
                        </li>
                        <li>
                            处理状态：
                            <select name="position">
                                <option value="">所有</option>
                                <option value="3">首页推荐</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-success" onclick="$.operate.add(0)" shiro:hasPermission="back:coupon:add">
                                <i class="fa fa-plus"></i> 新增
                            </a>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>

                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var listFlag = [[${@permission.hasPermi('back:coupon:list')}]];
    var editFlag = [[${@permission.hasPermi('back:coupon:edit')}]];
    var removeFlag = [[${@permission.hasPermi('back:coupon:remove')}]];
    var addFlag = [[${@permission.hasPermi('back:coupon:add')}]];
    var couponStatusDict = [[${@dict.getType('coupon_status')}]];
    var modelType = [[${@dict.getType('model_type')}]];
    var couponType = [[${@dict.getType('coupon_type')}]];
    var datas = [[${@dict.getType('is_enable')}]];
    var prefix = ctx + "back/coupon";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "优惠券",
            columns: [{
                radio: true
            },
                {
                    field : 'id',
                    title : '表id',
                    visible: false
                },
                {
                    field : 'title',
                    title : '优惠券名称'
                },
                {
                    field: 'type',
                    title: '优惠券类型',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(couponType, value);
                    }
                },
                {
                    field: 'modelType',
                    title: '模块类型',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(modelType, value);
                    }
                },
                {
                    field : 'overAmount',
                    title : '超额门槛'
                },
                {
                    field : 'reachAmount',
                    title : '使用门槛'
                },
                {
                    field : 'faceValue',
                    title : '面额'
                },
                {
                    field : 'discount',
                    title : '折扣值'
                },
                {
                    field : 'totalIssuance',
                    title : '总发放量'
                },
                {
                    field : 'totalGet',
                    title : '已领取数量'
                },
                {
                    field : 'totalUse',
                    title : '已使用数量'
                },
                {
                    field: 'couponStatus',
                    title: '状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(couponStatusDict, value);
                    }
                },
                {
                    field: 'isAbleActivity',
                    title: '是否注册赠送',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'isAbleShareGet',
                    title: '是否允许分享领取',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field : 'createTime',
                    title : '创建时间',
                    sortable: true
                },
                {
                    field : 'modifier',
                    title : '最后编辑者'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-primary btn-xs ' + addFlag + '" href="#" onclick="add(\'' + row.id + '\')"><i class="fa fa-edit">新增材料优惠券绑定</i></a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        // actions.push('<a class="btn btn-info btn-xs ' + listFlag + '" href="#" onclick="materialCouponList(\'' + row.id + '\')"><i class="fa fa-list-ul"></i>查看材料相关优惠券</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
/*

    /!*关联材料*!/
    function add(id) {
        var url = prefix + '/addCateCoupon?couponId=' + id;
        $.modal.open("关联材料", url, '800', '600');
    }

    /!*查看材料相关优惠券*!/
    function materialCouponList(id) {
        var url = prefix + '/materialCouponList?couponId=' + id;
        $.modal.openTab("查看材料分类相关优惠券", url);
    }
*/

</script>
</body>
</html>